﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.Sql;
using System.Data;
namespace Site
{
    public partial class RemoveUser : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnOK_Click(object sender, EventArgs e)
        {
            SqlDataSource1.SelectCommand = "SELECT * FROM Users WHERE userType='admin'";
            DataSourceSelectArguments Select = new DataSourceSelectArguments();
            DataView View = (DataView)SqlDataSource1.Select(Select);
            if (View.Count > 1)
            {
                SqlDataSource1.DeleteCommand = "DELETE FROM Users WHERE userID='" + DropDownList1.Text + "'";
                SqlDataSource1.Delete();
            }
            else
            {
                System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('Unable to delete user, ACCESS DENIED')</SCRIPT>");
            }
        }
    }
}